﻿using System;
using System.Collections.Generic;
using System.Text;
namespace shiloh.payment.main
{
    // 定义通用支付请求配置接口
    public interface IPaymentRequestConfig
    {
        string OrderId { get; set; }
        decimal Amount { get; set; }
        string Description { get; set; }
    }

    // 定义微信支付请求配置接口，继承自通用接口
    public interface IWechatPaymentRequestConfig : IPaymentRequestConfig
    {
        string WechatAppId { get; set; }
    }

    // 定义支付宝支付请求配置接口，继承自通用接口
    public interface IAlipayPaymentRequestConfig : IPaymentRequestConfig
    {
        string AlipayAppId { get; set; }
    }

    public interface IPaymentStrategy
    {
        void Pay<T>(Action<T> requestConfig) where T : IPaymentRequestConfig, new ();
    }

    /// <summary>
    /// 微信JSAPI支付实现类，必须基于公众号/小程序，拥有商户号
    /// </summary>
    public class WechatJsApiPaymentStrategy : IPaymentStrategy
    {
        /// <summary>
        /// 请求支付接口
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="requestConfig"></param>
        public void Pay<T>(Action<T> requestConfig) where T : IPaymentRequestConfig, new()
        {
            var request = new T();
            requestConfig?.Invoke(request);
        }

    }
}
